<template>
    <div>
        <HomePageHead></HomePageHead>
        <HomePageNavigation></HomePageNavigation>


        <div>当前皮肤：{{ skinId }}</div>
        <div>/sannongzixun/601517.html</div>
        <div><br/><br/><br/></div>
        <HomeSecondaryHeading :titleData="pageData" :pinyinid="routeId"></HomeSecondaryHeading>
        
        <!-- 页脚部分 -->
        <HomeFoot></HomeFoot>
    </div>
</template>

<script setup>
//0.pinia单基本信息 start---------------------------------------->
//0.1获得pinia源
import { useTemplateBaseStore } from '@/stores/templateBase'
const templateBaseStore = useTemplateBaseStore()
//0.2获得该页的皮肤id - 在每个组件中也是同样的获得方法
const skinId = ref("")
//0.3获得站点基本信息
let getTemplateBaseInfo = async () => {
    const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
        method: 'GET',
        query: {
            'link_textnum':24,
            'link_imgnum':18,
            'link_footnum':4
        },
    });
    if (responseStatus.code == 200) {
        templateBaseStore.setWebSiteInfo(responseStatus.data)
        skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
    }
}
getTemplateBaseInfo();
//0.4获得广告池
let getAdList = async (adKey) => {
    const responseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
        method: 'GET',
        query: {
            
        },
    });
    if (responseStatus.code == 200) {
        //console.log(responseStatus.data)
        templateBaseStore.setAdList(responseStatus.data)
        //获取广告
        //adImg.value = requestAd(templateBaseStore.webAdList,templateBaseStore.webSiteInfo.website_head.ad_key + "_" + "top")
    }
}
getAdList();
//0.5设置seo信息

//0.pinia单基本信息 end---------------------------------------->

//1.加载页面依赖 start ---------------------------------------->
import { ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
//1.加载页面依赖 end ---------------------------------------->

//2.获得路由id start ---------------------------------------->
const targetSegment = getRoutePath(1);
//2.1 获得当前的路由id
let routeId;
//通过导航路径反向查询导航id
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'pinyin': targetSegment,
    },
});
if (getRouteId.code == 200) {
    routeId = getRouteId.data.category_id
} else {
    console.log("获得路由id出错！", getRouteId.message)
}
//2.获得路由id end ---------------------------------------->

//4.页面数据 start ---------------------------------------->
//4.页面数据 end ---------------------------------------->

//5.设置seo信息 start---------------------------------------->
const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
    method: 'GET',
    query: {
        'catid': routeId
    },
});

if (setData.code == 200) {
    let seoTitle = setData.data.seo_title;
    let seoDescription = setData.data.seo_description;
    let seoKeywords = setData.data.seo_keywords;
    let seoSuffix = setData.data.suffix;
    let seoName = setData.data.website_name;

    useSeoMeta({
        title: seoTitle + "_" + seoSuffix,
        meta: [
            { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
            { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
        ]
    });
} else {
    console.log("设置频道页SEO出错！", setData.message)
}
//5.设置seo信息 end---------------------------------------->
</script>

<style lang="less" scoped>
@import '@/assets/css/class.less';
</style>